<?
define('MYEMAIL','huong@yellowpages.vn');//enquiry@yellowpages.com.vn
class sendEmail{
 var $subject;
 var $from;
 var $email;
 var $body;
 var $head;
 var $lang;
 var $nm;
 var $mails; 
 
 function sendEmail($p, $k, $lang){// print_r($p);
  $this->subject	= $_REQUEST['txtSubject'];
  $this->from		= $p[$k[3]];
  $this->email 		= 'huong@yellowpages.vn';//'quochuypro@gmail.com';
  $this->lang		= $lang;
 } 
 function getBody(){  return $this->body; }
 function setBody(){//istype, $_POST, k
  $a = func_get_args();// print_r($a);
  if($a[0]=='sa'){
   switch($this->lang){
    case 'vn':
	 $t="<font style=font-family:arial;font-size:12px><b>Đến Công Ty:</b> ".$a[1][$a[2][8]]."<br><b>Tên:</b> ".
   	   $a[1][$a[2][0]]."<BR><b>Công Ty:</b> ".$a[1][$a[2][1]]."<BR><b>Địa chỉ:</b> ".$a[1][$a[2][2]].
	   "<BR><b>Email:</b> ".$a[1][$a[2][3]]."<BR><b>Điện thoại:</b> ".$a[1][$a[2][4]]."<BR><br><font style=color:red>Dịch vụ bởi: YELLOWPAGES Vietnam-Niên giám doanh nghiệp duy nhất trên mạng tại Việt Nam<BR>
	   <b>Hà Nội:</b> (04) 7192302 &nbsp;&nbsp; <b>Bình Dương:</b> (0650) 759439 &nbsp;&nbsp; <BR><b>Hồ Chí Minh:</b>
	   (08) 4043838 &nbsp;&nbsp; <b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$a[1][$a[2][6]]."<PRE></font>";
	 break;
	case 'cn':
	 $t="<font style=font-family:arial;font-size:12px><b>你的名字:</b> ".$a[1][$a[2][8]]."<br><b>你的名字:</b> ".
   	   $a[1][$a[2][0]]."<BR><b>公司名称:</b> ".$a[1][$a[2][1]]."<BR><b>地址:</b> ".$a[1][$a[2][2]].
	   "<BR><b>电子邮件地址:</b> ".$a[1][$a[2][3]]."<BR><b>电话号码:</b> ".$a[1][$a[2][4]]."<BR><br><font style=color:red>由于:是在越南网站唯一的年鉴营业越南黄页<BR>
	   <b>河内:</b> (04) 7192302 &nbsp;&nbsp; <b>平阳省:</b> (0650) 759439 &nbsp;&nbsp; <BR><b>胡志明市:</b>
	   (08) 4043838 &nbsp;&nbsp; <b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$a[1][$a[2][6]]."<PRE></font>";
	 break;
	default:
     $t="<font style=font-family:arial;font-size:12px><b>To Company:</b> ".$a[1][$a[2][8]]."<br><b>User name:</b> ".
   	   $a[1][$a[2][0]]."<BR><b>Company:</b> ".$a[1][$a[2][1]]."<BR><b>Address:</b> ".$a[1][$a[2][2]].
	   "<BR><b>Email:</b> ".$a[1][$a[2][3]]."<BR><b>Phone Number:</b> ".$a[1][$a[2][4]]."<BR><br><font style=color:red>Service by: YELLOWPAGES Vietnam-The Only On-line Business Directory in Vietnam<BR>
	   <b>Hanoi:</b> (04) 7192302 &nbsp;&nbsp; <b>Binh Duong:</b> (0650) 759439 &nbsp;&nbsp;<BR><b>HCMC:</b>
	   (08) 4043838 &nbsp;&nbsp; <b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$a[1][$a[2][6]]."<PRE></font>";
   }
  }else{
   $pro = $this->getClassBrand('txtpro'); $brd = $this->getClassBrand('txtbrd');
   switch($this->lang){
    case 'vn':
	 $t = "<b>CẬP NHẬT THÔNG TIN</b><br><br><b>Tên Công ty tiếng anh:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][1]].
   		"<br><b>Tên công ty tiếng việt:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][0]]."<br><b>Tên Công ty tiếng hoa:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][2]]."<br><b>Địa chỉ:</b>&nbsp;&nbsp;<br>
		&nbsp; ".$a[1][$a[2][3]]."<br><b>Tỉnh/TP:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][6]]."<br><b>Số điện thoại:</b>&nbsp;&nbsp;
		&nbsp; ".$a[1][$a[2][9]]."<br><b>Số fax:</b>&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][10]]."<br><b>Email: </b>&nbsp;
		&nbsp;&nbsp;".$a[1][$a[2][4]]."<br><b>Website:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][5]]."<br><b>Giám đốc/Quản lý:</b>
		&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][7]]."<br><b>Chức danh:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][8]]."<br><b>Ngành nghề:</b>
		&nbsp;&nbsp;&nbsp;".$pro."<br><b>Thương hiệu:</b>&nbsp;&nbsp;&nbsp; ".$brd."<br><b>Người liên hệ:</b> &nbsp;&nbsp;
		&nbsp;".$a[1][$a[2][14]]."<br><b>Chức vụ:</b>&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][15]]."<br><b>Điện thoại liên hệ:</b>
		&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][16]]."<br><br><b>Chú thích:</b> &nbsp;&nbsp;&nbsp;
		<PRE style=font-family:arial>".$a[1][$a[2][17]]."<PRE>";
	 break;
	case 'us':
	 $t = "<b>UPDATE INFORMATION</b><br><br><b>English Company:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][1]].
   		"<br><b>Vietnamese name:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][0]]."<br><b>Chinese name:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][2]]."<br><b>Address:</b>&nbsp;&nbsp;&nbsp; ".
		$a[1][$a[2][3]]."<br><b>City:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][6]]."<br><b>Phone Number:</b>&nbsp;&nbsp;
		&nbsp; ".$a[1][$a[2][9]]."<br><b>Fax Number:</b>&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][10]]."<br><b>Email: </b>&nbsp;
		&nbsp;&nbsp;".$a[1][$a[2][4]]."<br><b>Website:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][5]]."<br><b>Director:</b>
		&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][7]]."<br><b>Designation:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][8]]."<br><b>Classes:</b>
		&nbsp;&nbsp;&nbsp;".$pro."<br><b>brands:</b>&nbsp;&nbsp;&nbsp; ".$brd."<br><b>Contact Person:</b> &nbsp;&nbsp;
		&nbsp;".$a[1][$a[2][14]]."<br><b>Position:</b>&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][15]]."<br><b>Contact Number:</b>
		&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][16]]."<br><br><b>Comments/Feedback:</b> &nbsp;&nbsp;&nbsp;
		<PRE style=font-family:arial>".$a[1][$a[2][17]]."<PRE>";
	 break;
	default:
	 $t = "<b>信息更新</b><br><br><b>公司名称越南:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][1]].
   		"<br><b>公司名称英文:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][0]]."<br><b>公司名称 中文:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][2]]."<br>
		<br><b>地址 ".$a[1][$a[2][3]]."<br><b>省/市:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][6]]."<br><b>电话号码
		&nbsp; ".$a[1][$a[2][9]]."<br><b>传真号码:</b>&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][10]]."<br><b>电子邮件: </b>&nbsp;
		&nbsp;&nbsp;".$a[1][$a[2][4]]."<br><b>网址:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][5]]."<br><b>主任/经理姓名:</b>
		&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][7]]."<br><b>名称:</b> &nbsp;&nbsp;&nbsp;".$a[1][$a[2][8]]."<br><b>行业:</b>
		&nbsp;&nbsp;&nbsp;".$pro."<br><b>品牌:</b>&nbsp;&nbsp;&nbsp; ".$brd."<br><b>联系人:</b> &nbsp;&nbsp;
		&nbsp;".$a[1][$a[2][14]]."<br><b>位置:</b>&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][15]]."<br><b>联络电话:</b>
		&nbsp;&nbsp;&nbsp; ".$a[1][$a[2][16]]."<br><br><b>评论/意见:</b> &nbsp;&nbsp;&nbsp;
		<PRE style=font-family:arial>".$a[1][$a[2][17]]."<PRE>";
   }
  }
  $this->body = $t;// echo($t);
 }
 function getHeader(){ return $this->head;}
 function setHeader($p, $k){ //print_r($p);
  if($p[$k[7]]) 
   $emails = $p[$k[7]];
  else
   $emails = 'huong@yellowpages.vn';//quochuypro@gmail.com*
   
  $headers  = "MIME-Version: 1.0 \r\n";
  $headers .= "Content-type: text/html; charset=utf-8 \r\n";
  if($p['flagit']=='sa'){
   $headers .= 'To: "'.$p['kw'].'"<'.$p['url']."> \r\n";
   $headers .= 'From: "'.$p[$k[1]].'"<'.$this->from."> \r\n";
   $headers .= "Bcc: huong@yellowpages.vn \r\n";
  }else{
   $headers .= 'To: "Chinh" <db@yellowpages.vn> '." \r\n";
   $headers .= "From: ".$p['txtEmail']." \r\n";
   
  }
  $this->head = $headers;
 }
 
 function sendit(){// $_POST, $k,$lang
  $a = func_get_args(); //print_r($a);
  $this->nm = $a[0]['kw'];
  $this->mails = $a[0][$a[1][7]];// echo($this->mails);
  
  $str = $this->changeLang($this->lang);
  if($this->mails===''){
   $this->email = "huong@yellowpages.vn";//'huong@yellowpages.com.vn'; 
   $t = $str[0];
  }else{
  $this->email = $this->mails;
   if($a[2]!=''){
    $t = $str[1];
   }else{
    $t = $str[2];
   }
  }
  if($_REQUEST['flagit']=='') $this->email='';
  mail($this->email,$this->subject,$this->body,$this->head);
//  mail("vanyen12@gmail.com",$this->subject,$this->body, $headers);
  //echo($this->email."<br>".$this->subject."<br>".$this->body."<br>".$this->head."<br>");
  echo($t);
 }
 function getClassBrand($nm){
  $t='';
  for($i=0;$i<count($_REQUEST[$nm]);$i++){
   if($_REQUEST[$nm][$i]!='') $t .=$_REQUEST[$nm][$i]."; ";
  }
  return substr($t,0,strlen($t)-2);
 }
 function changeLang($lang){
  $a = array();
  switch($lang){
   case 'us':
    $a[]="<tr><td vAlign=bottom align=center height=50><b>Your enquiry has sent successfully.</b></td></tr>
		<tr><td height=10></td></tr>
		<tr><td vAlign=top align=middle>Thank you for writing us. Because of your company you enquiried doesn't have 
		email address, we will contact the company and reply as 
		soon as possible. <p>&nbsp;</td></tr>";
	$a[]="<table class=tab cellpadding=5 cellspacing=0><tr><td>Company Name</td><td>".$this->nm."</td></tr>
	  <tr><td>Email</td><td>".$this->mails."</td></tr>
	  <tr><td align=center nowrap colspan=2>Thank you for writing us. We will reply your enquiry as soon as possible.</td>
	  </tr></table>";
	$a[]="<table class=tab cellpadding=5 cellspacing=0><tr><td>Your enquiry has been sent successfully. <br>Company Name: 
	  &nbsp;&nbsp;Yellowpages <br>Email :&nbsp;&nbsp;db@yellowpages.com.vn <br>Thank you for writing us. We will reply your
	  enquiry as soon as possible. </td></tr></table>";
	break;
   case 'vn':
   $a[]="<tr><td vAlign=bottom align=center height=50><b>Yêu cầu của bạn đã được gửi đi thành công.</b></td></tr>
		<tr><td height=20></td></tr>
		<tr><td vAlign=top align=middle>Cám ơn bạn đã gửi yêu cầu đến chúng tôi. Công ty bạn liên hệ hiện chưa có địa chỉ email, 
   	   chúng tôi sẽ liên hệ giúp bạn trong thời gian sớm nhất.</td></tr>";
	$a[]="<table class=tab cellpadding=5 cellspacing=0><tr><td>Tên Công Ty</td><td>".$this->nm."</td></tr>
	  <tr><td>Email</td><td>".$this->mails."</td></tr>
	  <tr><td align=center nowrap colspan=2>Cám ơn bạn đã gửi yêu cầu đến chúng tôi. Chúng tôi sẽ trả lời bạn trong thời gian sớm nhất.</td>
	  </tr></table>";
	$a[]="<table class=tab cellpadding=5 cellspacing=0><tr><td>Yêu cầu của bạn đã được gửi đi thành công. <br>Tên Công Ty: 
	  &nbsp;&nbsp;Yellowpages <br>Email :&nbsp;&nbsp;db@yellowpages.com.vn <br>Cám ơn bạn đã gửi yêu cầu đến chúng tôi. Chúng tôi sẽ trả lời bạn trong thời gian sớm nhất.
	</td></tr></table>";
    break;
   case 'cn':
   $a[]="<tr><td vAlign=bottom align=center height=50><b>你的要求已寄成功.</b></td></tr>
		<tr><td height=20></td></tr>
		<tr><td vAlign=top align=middle>谢谢你已寄要求给我们.你的公司没有联络电邮地址, 
   	     我们为提早时间来联络你.</td></tr>";
	$a[]="<table class=tab cellpadding=5 cellspacing=0><tr><td>公司名称</td><td>".$this->nm."</td></tr>
	  <tr><td>电子邮件</td><td>".$this->mails."</td></tr>
	  <tr><td align=center nowrap colspan=2>谢谢你已寄要求给我们.我们为提早时间来回答你.</td>
	  </tr></table>";
	$a[]="<table class=tab cellpadding=5 cellspacing=0><tr><td>你的要求已寄成功. <br>公司名称: 
	  &nbsp;&nbsp;Yellowpages <br>Email :&nbsp;&nbsp;db@yellowpages.com.vn <br>谢谢你已寄要求给我们.我们为提早时间来回答你.</td></tr></table>";
    break;
  }
  return $a; 
 }
}
?>